/**
 * Copyright (c) 2020 kedacom
 * OpenATC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 * http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 **/
package com.openatc.agent.service;


import com.openatc.agent.model.RolePermission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;


public interface RolePermissionDao extends JpaRepository<RolePermission, Integer>{


    @Modifying
    @Transactional
    @Query(value="insert into t_role_permission(id,role_id,permission_id) values (DEFAULT,?1,?2)",nativeQuery=true)
    void updateRoleByUser(int roleid, Integer permission);
    @Modifying
    @Transactional
    @Query(value="delete from  t_role_permission t where t.role_id = ?1",nativeQuery=true)
    void deleteAllByRoleId( int roleId );


}
